import pymysql

class DB_connect:

    def __init__(self, host='vdb31201.uat1.rs.com', port=6033, userName='u_redstar_erp', passWord='Z7hGPG3ne7bdpJA1iEIR'):
        self.host = host
        self.port = port
        self.userName = userName
        self.passWord = passWord
        self.conn = pymysql.connect(host=self.host, port=self.port, user=self.userName, passwd=self.passWord)
        self.cur = self.conn.cursor()

    def excute(self,sql):
        self.cur.execute(sql)
        result = self.cur.fetchall()
        self.conn.commit()
        # print(result)
        return result

    def selectSql(self,sql):
        self.cur.execute(sql)
        result = self.cur.fetchall()
        return result



a = DB_connect()
# select_brand_name = '''select brand_code, brand_name from db_redstar_erp_investment.invest_brand order by create_time desc limit 10;'''
select_brand_enableStatus = '''select id from db_redstar_erp_investment.invest_brand where enable_status = 1 order by create_time desc limit 1;'''
result = a.selectSql(select_brand_enableStatus)
print(result[0][0])

